<style lang="less" rel="stylesheet/less" type="text/less">
.api-book {
  padding-left: 20px;
  padding-bottom: 20px;
}
</style>

<template>
  <div class="api-book">
    <index :data="dataList" @toRouter="toDetail" @toApifun="toApifunction" />
  </div>
</template>
<script>
import qs from "qs";
import index from "./index.vue";

export default {
  components: {
    index
  },
  data() {
    return {
      dataList: [],
      detailData: []
    };
  },
  created() {
    this.$Spin.show();
    this.APIBOOKLIST();
  },
  methods: {
    APIBOOKLIST() {
      this.axios
        .get(`${window.location.origin}/admin/api/v1/docs?group=face`)
        .then(({ data }) => {
          if (data.code === 200) {
            this.dataList = data.apiDocs;
            this.$Spin.hide();
          } else {
            throw new Error(data.error);
          }
        })
        .catch(err => {
          this.$Message.error({
            content: err.message || err.statusText,
            duration: 5,
            closable: true
          });
        });
    },
    toDetail(name) {
      this.$router.push({
        path: `/api/${name}`,
        params: {
          name
        }
      });
    },

    toApifunction(name) {
      this.$router.push({
        path: `${name}`,
        params: {
          name
        }
      });
    }
  }
};
</script>
